# -*- coding: UTF-8 -*-
from typing import List
from leetcode_helper import TestcaseHelper, SolutionBase


class Solution(SolutionBase):
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        nums_dict = {}
        for index, value in enumerate(nums):
            part_index = nums_dict.get(target - value, -1)
            if part_index != -1:
                return [index, part_index]
            else:
                nums_dict[value] = index

        return [0, 0]

    # 检查结果是否正确的方法，不同的case，检查方法不同
    def check_result(self, expect, result) -> bool:
        return self.check_result_array(expect, result)


if __name__ == '__main__':
    solution = Solution()
    testcases = [
        ([0, 3, 0], 3, [0, 1])
    ]

    for item in testcases:
        input1 = item[0]
        input2 = item[1]
        expect = item[len(item) - 1]

        result = solution.twoSum(input1, input2)

        pass_result = solution.check_result(expect, result)
        TestcaseHelper.print_case(pass_result, item, result)
